package com.sctvcloud.zhaohua_sd.ui.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.jiongbull.jlog.JLog;
import com.ruihang.generalibrary.ui.adapter.BaseHolderAbsAdapter;
import com.sctvcloud.zhaohua_sd.R;
import com.sctvcloud.zhaohua_sd.beans.FComment;
import com.sctvcloud.zhaohua_sd.ui.adapter.holder.CLCommentHolder;

import java.util.List;

/**
 * Created by liuyu on 2017/8/22.
 */

public class NewCommentAdapter extends BaseHolderAbsAdapter<FComment, CLCommentHolder> {

    public NewCommentAdapter(Context context, List<FComment> list) {
        super(context, list);
    }

    @Override
    public int getItemCount() {
        if (data!=null){
            int size=data.size();
//            if (size>5){
//                return 5;
//            }
            return size;
        }
        return 0;
    }

    @Override
    public CLCommentHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(context).inflate(R.layout.item_comment_cl, parent, false);
//        View v = LayoutInflater.from(context).inflate(R.layout.item_topic_detail_comment, parent, false);
        CLCommentHolder clh = new CLCommentHolder(context,data, v);
        clh.setInternalClick(this);
        return clh;
    }

    @Override
    public void onBindViewHolder(CLCommentHolder holder, int position) {
        super.onBindViewHolder(holder, position);
//        holder.setItemMode(position == getItemCount() - 1 ? BaseAbsHolder.ITEMMODE_LAST : BaseAbsHolder.ITEMMODE_NORMAL);
    }

    @Override
    public void onItemInternalClick(View itemView, View view, int position) {
        JLog.e("internal click "+itemInternalClick);
        super.onItemInternalClick(itemView, view, position);
    }
}
